<?php

use yii\helpers\Html;
use kartik\grid\GridView;
use common\helpers\StringHelper;
use common\widgets\ueditor\Ueditor;

$this->title = 'News';
?>
<div class="blog-index">
    <!--选项卡开始-->
    <?php
    echo \yii\bootstrap\Tabs::widget([
        'items' => [
            [
                'label' => '未联系',
                'url' => '/contact/index?active=all',
                'active' => $active == 'all' ? true : false
            ],
            [
                'label' => '已联系',
                'url' => '/contact/index?active=draft',
                'active' => $active == 'draft' ? true : false
            ],
        ],
    ]);
    ?>
    <?= GridView::widget([
        'responsiveWrap' => false,
        'dataProvider' => $dataProvider,
        'columns' => [
            'id',
            'username',
            'phone',
            [
                'attribute' => 'content',
                'format'=>'raw',
                'value' => function ($model) {
                    return  substr($model->content,0,50);
                }
            ],
            'ctime',
            [
                'class' => 'kartik\grid\ActionColumn',
                'template' => '{view}{replay}{delete}',
                'buttons' => [
                    'view' => function ($url, $model) {
                        return Html::a('<span class="glyphicon glyphicon-eye-open"></span>查看', $url, [
                            'title' => Yii::t('yii', 'View'),
                            'class' => 'btn btn-xs btn-default'
                        ]);
                    },
                    'replay' => function ($url, $model) {
                        return Html::a('<span class=" glyphicon glyphicon-pencil"></span>回复', $url, [
                            'title' => Yii::t('yii', 'replay'),
                            'class' => 'btn btn-xs btn-primary'
                        ]);
                    },
                    'delete' => function ($url, $model) {
                        return Html::a('<span class=" glyphicon glyphicon-pencil"></span>删除', $url, [
                            'title' => Yii::t('yii', 'Delete'),
                            'class' => 'btn btn-xs btn-primary',
                            'data' => [
                                'confirm' => '你确认要删除？',
                                'method' => 'post',
                            ],
                        ]);
                    }
                ]
            ],
        ],
    ]); ?>

</div>
